package com.wilmer.children.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wilmer.common.annotation.Log;
import com.wilmer.common.core.controller.BaseController;
import com.wilmer.common.core.domain.AjaxResult;
import com.wilmer.common.enums.BusinessType;
import com.wilmer.children.domain.YwGrowthArchive;
import com.wilmer.children.service.IYwGrowthArchiveService;
import com.wilmer.common.utils.poi.ExcelUtil;
import com.wilmer.common.core.page.TableDataInfo;

/**
 * archiveController
 * 
 * @author hans
 * @date 2024-05-19
 */
@RestController
@RequestMapping("/archive/archive")
public class YwGrowthArchiveController extends BaseController
{
    @Autowired
    private IYwGrowthArchiveService ywGrowthArchiveService;

    /**
     * 查询archive列表
     */
    @PreAuthorize("@ss.hasPermi('archive:archive:list')")
    @GetMapping("/list")
    public TableDataInfo list(YwGrowthArchive ywGrowthArchive)
    {
        startPage();
        List<YwGrowthArchive> list = ywGrowthArchiveService.selectYwGrowthArchiveList(ywGrowthArchive);
        return getDataTable(list);
    }

    /**
     * 导出archive列表
     */
    @PreAuthorize("@ss.hasPermi('archive:archive:export')")
    @Log(title = "archive", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YwGrowthArchive ywGrowthArchive)
    {
        List<YwGrowthArchive> list = ywGrowthArchiveService.selectYwGrowthArchiveList(ywGrowthArchive);
        ExcelUtil<YwGrowthArchive> util = new ExcelUtil<YwGrowthArchive>(YwGrowthArchive.class);
        util.exportExcel(response, list, "archive数据");
    }

    /**
     * 获取archive详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:archive:query')")
    @GetMapping(value = "/{archiveId}")
    public AjaxResult getInfo(@PathVariable("archiveId") Long archiveId)
    {
        return success(ywGrowthArchiveService.selectYwGrowthArchiveByArchiveId(archiveId));
    }

    /**
     * 新增archive
     */
    @PreAuthorize("@ss.hasPermi('archive:archive:add')")
    @Log(title = "archive", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YwGrowthArchive ywGrowthArchive)
    {
        return toAjax(ywGrowthArchiveService.insertYwGrowthArchive(ywGrowthArchive));
    }

    /**
     * 修改archive
     */
    @PreAuthorize("@ss.hasPermi('archive:archive:edit')")
    @Log(title = "archive", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YwGrowthArchive ywGrowthArchive)
    {
        return toAjax(ywGrowthArchiveService.updateYwGrowthArchive(ywGrowthArchive));
    }

    /**
     * 删除archive
     */
    @PreAuthorize("@ss.hasPermi('archive:archive:remove')")
    @Log(title = "archive", businessType = BusinessType.DELETE)
	@DeleteMapping("/{archiveIds}")
    public AjaxResult remove(@PathVariable Long[] archiveIds)
    {
        return toAjax(ywGrowthArchiveService.deleteYwGrowthArchiveByArchiveIds(archiveIds));
    }
}
